package com.platform.task.job;

import org.apache.log4j.Logger;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;

/**
 * 通过spring Quartz指定时间定时执行任务，需要在xml配置定时任务，操作比较麻烦
 */
public class StrategyStatusTask extends QuartzJobBean {

	private static Logger log = Logger.getLogger(StrategyStatusTask.class);
	/**
	 * 是否开启定时任务
	 */
	private String switchs;

	@Override
	protected void executeInternal(JobExecutionContext jobContext) throws JobExecutionException {
		try {
			log.debug("Task Begin.................");
			doWork();
			log.debug("Task End............");
		} catch (Throwable e) {
			log.error("Task fail........ ", e);
		}
	}

	private void doWork() throws Exception {
		if (switchs.equals("ON")) {
			// 执行 业务处理
		}
	}

	public String getSwitchs() {
		return switchs;
	}

	public void setSwitchs(String switchs) {
		this.switchs = switchs;
	}
}